const http = require('http')
const fs = require('fs')

const server = http.createServer((req,res)=> {
  let matched = req.url.match();
  let filename = match && matched[1]
  if(!filename) 
     return
  let writeStream = fs.createWriteStream("../server/public/" + filename)
  req.pipe(writeStream)
  req.on('end',()=>{
      res.writeHead(200,{ 'Content-Type': 'text/plan'})
      res.end('okay')
  })
})

server.listen(3001)